package com.lance;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author lancecong
 * @version 1.0
 * @ClassName NacosConsumerApplication
 * @DESCRIPTION TODO
 * @create 2019-06-15 20:57
 **/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class NacosConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(NacosConsumerApplication.class, args);
    }

    @Slf4j
    @RestController
    static class TestController {

        @Resource
        Provider provider;

        @GetMapping("/test")
        public String test() {
            String result = provider.getConfiger();
            return "Return : " + result;
        }
    }

        //注意这里调用的是在注册中心的名称
        @FeignClient("micro-nacos")
        public interface Provider{
            @GetMapping("/conf/get")
            String getConfiger();
        }

}

